Fix problems with HandleBox and focusing - #78232
authorOwen Taylor <otaylor@redhat.com>
Tue, 9 Apr 2002 23:32:35 +0000 (23:32 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Tue, 9 Apr 2002 23:32:35 +0000 (23:32 +0000)
Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>

        Fix problems with HandleBox and focusing - #78232

* gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
GtkHandleBox / GnomeDock style window heirarchy / widget
heirarchy disconnects. :-(.

* gtk/gtkcontainer.c: Handle failures from
gtk_widget_translate_coordinates (Focusing is not right, but at
least it doesn't go into infinite loops.)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkcontainer.c
gtk/gtkwidget.c

index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index c643fc778b956213d542cccde2c16f8b54df89a4..bf30889e5f3e9e937e3eb00a538553ad60badd09 100644 (file)
@@ -1,3 +1,15 @@
+Tue Apr  9 19:01:28 2002  Owen Taylor  <otaylor@redhat.com>
+
+        Fix problems with HandleBox and focusing - #78232
+
+       * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Handle
+       GtkHandleBox / GnomeDock style window heirarchy / widget
+       heirarchy disconnects. :-(. 
+
+       * gtk/gtkcontainer.c: Handle failures from
+       gtk_widget_translate_coordinates (Focusing is not right, but at
+       least it doesn't go into infinite loops.)
+
 Tue Apr  9 18:34:58 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkcontainer.c (_gtk_container_queue_resize): Always
index f35ab73254433a758688af47eb3f6bff10a48545..b9aeea334eef04c1831941ee492246ff13d44737 100644 (file)
@@ -1564,8 +1564,10 @@ up_down_compare (gconstpointer a,
   CompareInfo *compare = data;
   gint y1, y2;
 
-  get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1);
-  get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2);
+  if (!get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1))
+    return 0;
+  if (!get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2))
+    return 0;
 
   y1 = allocation1.y + allocation1.height / 2;
   y2 = allocation2.y + allocation2.height / 2;
@@ -1592,6 +1594,7 @@ gtk_container_focus_sort_up_down (GtkContainer     *container,
 {
   CompareInfo compare;
   GList *tmp_list;
+  GdkRectangle old_allocation;
 
   compare.container = container;
   compare.reverse = (direction == GTK_DIR_UP);
@@ -1599,17 +1602,14 @@ gtk_container_focus_sort_up_down (GtkContainer     *container,
   if (!old_focus)
       old_focus = find_old_focus (container, children);
   
-  if (old_focus)
+  if (old_focus && get_allocation_coords (container, old_focus, &old_allocation))
     {
-      GdkRectangle old_allocation;
       gint compare_x1;
       gint compare_x2;
       gint compare_y;
 
       /* Delete widgets from list that don't match minimum criteria */
 
-      get_allocation_coords (container, old_focus, &old_allocation);
-
       compare_x1 = old_allocation.x;
       compare_x2 = old_allocation.x + old_allocation.width;
 
@@ -1628,17 +1628,20 @@ gtk_container_focus_sort_up_down (GtkContainer     *container,
          
          if (child != old_focus)
            {
-             get_allocation_coords (container, child, &child_allocation);
-             
-             child_x1 = child_allocation.x;
-             child_x2 = child_allocation.x + child_allocation.width;
-             
-             if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ ||
-                 (direction == GTK_DIR_DOWN && child_allocation.y + child_allocation.height < compare_y) || /* Not below */
-                 (direction == GTK_DIR_UP && child_allocation.y > compare_y)) /* Not above */
+             if (get_allocation_coords (container, child, &child_allocation))
                {
-                 children = g_list_delete_link (children, tmp_list);
+                 child_x1 = child_allocation.x;
+                 child_x2 = child_allocation.x + child_allocation.width;
+                 
+                 if ((child_x2 <= compare_x1 || child_x1 >= compare_x2) /* No horizontal overlap */ ||
+                     (direction == GTK_DIR_DOWN && child_allocation.y + child_allocation.height < compare_y) || /* Not below */
+                     (direction == GTK_DIR_UP && child_allocation.y > compare_y)) /* Not above */
+                   {
+                     children = g_list_delete_link (children, tmp_list);
+                   }
                }
+             else
+               children = g_list_delete_link (children, tmp_list);
            }
          
          tmp_list = next;
@@ -1690,8 +1693,10 @@ left_right_compare (gconstpointer a,
   CompareInfo *compare = data;
   gint x1, x2;
 
-  get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1);
-  get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2);
+  if (!get_allocation_coords (compare->container, (GtkWidget *)a, &allocation1))
+    return 0;
+  if (!get_allocation_coords (compare->container, (GtkWidget *)b, &allocation2))
+    return 0;
 
   x1 = allocation1.x + allocation1.width / 2;
   x2 = allocation2.x + allocation2.width / 2;
@@ -1718,6 +1723,7 @@ gtk_container_focus_sort_left_right (GtkContainer     *container,
 {
   CompareInfo compare;
   GList *tmp_list;
+  GdkRectangle old_allocation;
 
   compare.container = container;
   compare.reverse = (direction == GTK_DIR_LEFT);
@@ -1725,18 +1731,14 @@ gtk_container_focus_sort_left_right (GtkContainer     *container,
   if (!old_focus)
     old_focus = find_old_focus (container, children);
   
-  if (old_focus)
+  if (old_focus && get_allocation_coords (container, old_focus, &old_allocation))
     {
-      GdkRectangle old_allocation;
-
       gint compare_y1;
       gint compare_y2;
       gint compare_x;
       
       /* Delete widgets from list that don't match minimum criteria */
 
-      get_allocation_coords (container, old_focus, &old_allocation);
-
       compare_y1 = old_allocation.y;
       compare_y2 = old_allocation.y + old_allocation.height;
 
@@ -1755,17 +1757,20 @@ gtk_container_focus_sort_left_right (GtkContainer     *container,
          
          if (child != old_focus)
            {
-             get_allocation_coords (container, child, &child_allocation);
-             
-             child_y1 = child_allocation.y;
-             child_y2 = child_allocation.y + child_allocation.height;
-             
-             if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ ||
-                 (direction == GTK_DIR_RIGHT && child_allocation.x + child_allocation.width < compare_x) || /* Not to left */
-                 (direction == GTK_DIR_LEFT && child_allocation.x > compare_x)) /* Not to right */
+             if (get_allocation_coords (container, child, &child_allocation))
                {
-                 children = g_list_delete_link (children, tmp_list);
+                 child_y1 = child_allocation.y;
+                 child_y2 = child_allocation.y + child_allocation.height;
+                 
+                 if ((child_y2 <= compare_y1 || child_y1 >= compare_y2) /* No vertical overlap */ ||
+                     (direction == GTK_DIR_RIGHT && child_allocation.x + child_allocation.width < compare_x) || /* Not to left */
+                     (direction == GTK_DIR_LEFT && child_allocation.x > compare_x)) /* Not to right */
+                   {
+                     children = g_list_delete_link (children, tmp_list);
+                   }
                }
+             else
+               children = g_list_delete_link (children, tmp_list);
            }
          
          tmp_list = next;
index 8a91b0ac3e10cc5e705ef38e260fb940ecaa9aa3..16587033dddfcef154a7261de0a119c5a0c4230d 100644 (file)
@@ -2481,6 +2481,9 @@ gtk_widget_translate_coordinates (GtkWidget  *src_widget,
       src_y += dy;
       
       window = gdk_window_get_parent (window);
+
+      if (!window)             /* Handle GtkHandleBox */
+       return FALSE;
     }
 
   /* And back */
@@ -2495,6 +2498,9 @@ gtk_widget_translate_coordinates (GtkWidget  *src_widget,
       src_y -= dy;
       
       window = gdk_window_get_parent (window);
+      
+      if (!window)             /* Handle GtkHandleBox */
+       return FALSE;
     }
 
   /* Translate from window relative to allocation relative */